package com.ebs.md.api.abs;

/**
 * Perforce Revision:
 *  $File: //depot/MarketData/commons-md-api/MAIN/src/main/java/com/ebs/md/api/abs/BasicIdentifiedOrder.java $
 *  $Revision: #6 $  $Change: 115126 $  $DateTime: 2012/09/23 15:15:49 $  $Author: Aviad.Yosef $
 */

import java.util.Calendar;

import com.ebs.md.api.IIdentifiedOrder;
import com.ebs.md.api.IProduct;
import com.ebs.md.api.OrderOperation;
import com.ebs.md.api.OrderSide;
import com.ebs.md.api.Rate;


public class BasicIdentifiedOrder
implements IIdentifiedOrder
{
	// gened via Eclipse
	private static final long serialVersionUID = -648980809470111247L;

	protected IProduct  product;
	
	protected Rate  rate;
	protected Long  amount;      // available amount
	protected OrderSide      side;
	protected OrderOperation operation;
	protected Long  totalAmount; // total amount
	protected Long  displayAmount; // display amount
	
	protected String   id; // quote_id (qte_id)
	protected Calendar time;
	protected String   dealCode;
	protected String   traderId;
	protected String   region;
	
	public BasicIdentifiedOrder(IProduct product, long amount, OrderSide side, OrderOperation operation
			, Rate rate, long totalAmount, long displayAmount, String region) {
		super();
		this.product= product;
		this.amount = amount;
		this.side      = side;
		this.operation = operation;
		this.rate   = rate;
		this.totalAmount = totalAmount;
		this.displayAmount = displayAmount;
		this.region = region;
	}
	
	public BasicIdentifiedOrder(IProduct product, long amount, OrderSide side, OrderOperation operation
			, Rate rate, long totalAmount, String region) {
		this(product, amount, side, operation, rate, totalAmount, amount, region);
	}
	
	public BasicIdentifiedOrder(IProduct product, long amount, OrderSide side, OrderOperation operation
			, Rate rate
			, String id, Calendar time, String dealCode, String traderId, String region
	) {
		this(product, amount, side, operation, rate, amount, region);
		setIdentifiers(id, time, dealCode, traderId);
	}
	
	public BasicIdentifiedOrder(IProduct product, long amount, OrderSide side, OrderOperation operation
			, String id, Calendar time, String dealCode, String traderId, String region
			) {
		this(product, amount, side, operation, null, amount, region);
		setIdentifiers(id, time, dealCode, traderId);
	}

	public BasicIdentifiedOrder(IProduct product, long amount, OrderSide side, OrderOperation operation
			, Rate rate
			, String id, Calendar time, String dealCode, String traderId
			, long totalAmount, String region
	) {
		this(product, amount, side, operation, rate, totalAmount, amount, region);
		setIdentifiers(id, time, dealCode, traderId);
	}
	
	public BasicIdentifiedOrder(IProduct product, long amount, OrderSide side, OrderOperation operation
			, Rate rate
			, String id, Calendar time, String dealCode, String traderId
			, long totalAmount, long displayAmount, String region
	) {
		this(product, amount, side, operation, rate, totalAmount, displayAmount, region);
		setIdentifiers(id, time, dealCode, traderId);
	}

	public void setIdentifiers(String id, Calendar time, String dealCode, String traderId) {
		this.id   = id;
		this.time = time;
		this.dealCode = dealCode;
		this.traderId = traderId;
	}


	public IProduct getProduct() {
		return product;
	}
	public OrderSide getSide() {
		return side;
	}
	public Rate getRate() {
		return rate;
	}
	public Long getAmount() {
		return amount;
	}
	public OrderOperation getOperation() {
		return operation;
	}
	public Long getTotalAmount() {
		return totalAmount;
	}
	public Long getDisplayAmount() {
		return displayAmount;
	}
	public String getId() {
		return id;
	}
	public Calendar getTime() {
		return time;
	}
	public String getDealCode() {
		return dealCode;
	}
	public String getTraderId() {
		return traderId;
	}
	public String getRegion() {
		return region;
	}
	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		
		sb.append(  "id=");
		sb.append(   id);
		sb.append(", product=");
		sb.append(   product);
		sb.append(", side=");
		sb.append(   side);
		sb.append(", amount=");
		sb.append(   amount);
		sb.append(", rate=");
		sb.append(   rate);
		sb.append(", operation=");
		sb.append(   operation);
		sb.append(", totalAmount=");
		sb.append(   totalAmount);
		sb.append(", displayAmount=");
		sb.append(   displayAmount);
		sb.append(", time=");
		sb.append(", region=");
		sb.append(   region);
		if ( time == null ) {
			sb.append( "null");
		} else {
			sb.append(  time.getTime());
		}
		
		return sb.toString();
	}
	
}
